/**
 * Demonstrates a range of Button options the framework offers out of the box
 */
Ext.define('cloud.view.homepic.AdpicEdit', {
    extend: 'Ext.form.FormPanel',
    xtype: 'adpicEdit',

    requires: ['Ext.form.Panel', 'Ext.form.FieldSet', 'Ext.field.Select', 'Ext.field.Hidden'],
    config: {
        title: '广告详情',
        items: [
            {
                xtype: 'toolbar',
                docked: 'bottom',
                layout: {
                    type: 'hbox',
                    pack: 'end'
                },
                items: [
                    {
                        id: 'adpic_edit',
                        iconMask: true,
                        scope: this,
                        cls:'x-button2',
                        text: '修改提交',
                        style: 'float:right'
                    },
                    {
                        id: 'adpic_delet',
                        iconMask: true,
                        scope: this,
                        cls:'x-button2',
                        text: '删除',
                        style: 'float:right'
                    }
                ]
            },
            {
                xtype: 'fieldset',
                title: '广告详情',
                items: [
                    {
                        xtype:'selectfield',
                        label:'选择地区',
                        name:'cadid',
                        store:'AreaAllFindStore',
                        id:'adpic_cadid_edit',
                        displayField: 'name',
                        valueField: 'cadid',
                        listeners:{
                            initialize: function () {
                                var caid=localStorage.getItem('caid');
                                var store = Ext.getStore('AreaAllFindStore');
                                store.load({params: {caid: caid}});
                            },
                            change: function () {
                                var cadid=Ext.getCmp('adpic_cadid_edit').getValue();
                                var store = Ext.getStore('ProductAllFullFindStore');
                                store.load({params: {cadid: cadid}});
                            }
                        }
                    },
                    {
                        xtype:'selectfield',
                        label:'连接的产品',
                        name:'linkProduct',
                        id:'adpic_linkProduct_edit',
                        displayField: 'name',
                        valueField: 'cpid',
                        store:'ProductAllFullFindStore',
                        listeners:{
                            initialize: function () {
                                var cadid=Ext.getCmp('adpic_cadid_edit').getValue();
                                var store = Ext.getStore('ProductAllFullFindStore');
                                store.load({params: {cadid: cadid}});
                            }
                        }
                    },
                    {
                        xtype:'textfield',
                        label:'广告地址',
                        name:'picUrl',
                        id:'adpic_update_picUrl',
                        hidden:true
                    },
                    {
                        xtype: 'textfield',
                        label:'广告ID',
                        id:'adpic_cdaid_edit',
                        name: 'cdaid',
                        readOnly:true,
                        hidden:true
                    },
                    {
                        xtype:'textfield',
                        label:'广告名',
                        name:'name',
                        id:'adpic_name_edit'
                    },
                    {
                        xtype:'textareafield',
                        label:'说明',
                        name:'explain',
                        id:'adpic_explain_edit'
                    },
                    {
                        xtype:'selectfield',
                        label:'排序',
                        name:'display',
                        id:'adpic_display_edit',
                        options: [
                            {text: '1',  value: '1'},
                            {text: '2', value: '2'},
                            {text: '3',  value: '3'},
                            {text: '4',  value: '4'},
                            {text: '5', value: '5'},
                            {text: '6',  value: '6'},
                            {text: '7',  value: '7'},
                            {text: '8', value: '8'},
                            {text: '9',  value: '9'},
                            {text: '10',  value: '10'}
                        ]
                    },
                    {
                        id:'adpic_upload',
                        style:'margin:10px',
                        html:'<input id="adpic_img"  type="file" onchange="previewImage(this)"  />'
                    },
                    {
                        id:'adpic_showImage',
                        html:'<div id="preview"><img id="imghead" width=150 height=150 src=""></div>'
                    }
                ]
            }
        ]
    }
});
